<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
      .wrapper {
        display: flex;
      }
      .left {
        width: 100px;
      }
      .right {
        flex: 1;
      }
    </style>
</head>
<body>
  <section class="wrapper">
    <div class="left">left content</div>
    <div class="right">right content</div>
  </section>
  <button id="test">按钮</button>
  <div>
    4 3 4 5
  </div>
  <script>
      const testNode = document.getElementById('test');
      testNode.onclick = () => debouceFn()
      function fn() {
          testNode.disabled = true
          fetch().then(res=>{
              // 操作
              testNode.disabled = false
          }).catch(() => {
              testNode.disabled = false
          })
      }

      const getAttribute = (object, path, defaultValue) => {
          const pathArr = path.split('.')
          let res = object
          pathArr.forEach((item, index) => {
              res = res[item] ? res[item] : defaultValue
          })
          console.log(res)
      }

      const getQueryParams = () => {
          const params = new URLSearchParams(window.location.search);
          const res = {}
          params.forEach((value, name) => {
              res[name] = value
          });
          return res
      }

      const debouce = (fn, wait = 500, immed = false) => {
          let timer = null, flag = true;
          return function(...args){
              let that = this
              clearTimeout(timer)
              if(immed){
                  if(flag){
                      fn.apply(that, args)
                      flag = false
                  }
                  timer = setTimeout(function(){
                      flag = true
                  }, wait)
              }else{
                  timer = setTimeout(function(){
                      fn.apply(that, args)
                  }, wait)
              }
          }
      };
      const fn2 = () => { console.log('hi'); }
      const debouceFn = debouce(fn2, 1000, true);
  </script>
</body>
</html>